package com.clkj.mobileinspector.ui.dialog;


import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;


import com.chad.library.adapter.base.BaseQuickAdapter;
import com.clkj.mobileinspector.R;
import com.clkj.mobileinspector.ui.view.LinePathView;
import com.lws.basic.base.BaseDialogFragment;
import com.lws.basic.utils.common.MyLogger;
import com.lws.basic.utils.common.MyToast;
import com.lws.basic.utils.common.TimeUtils;

import java.io.IOException;
import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * @松 2020/4/9 14:07
 * 闸机列表
 */
public class SignatureDialog extends BaseDialogFragment {
    @BindView(R.id.view)
    LinePathView mLinePathView;
    Unbinder unbinder;
    private I mI;



    @Override
    public int setLayoutId() {
        return R.layout.dialog_signature;
    }


    @Override
    protected void initWindow(Window window) {
        setLayoutParams(window, Gravity.CENTER, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, 0, 0);
    }

    @Override
    protected void initData(View rootView) {
        super.initData(rootView);
        unbinder = ButterKnife.bind(this, rootView);

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }


    @OnClick(R.id.btn_confirm)
    public void onViewClicked() {

        if (mLinePathView.getTouched()) {
            try {
                String path = getActivity().getFilesDir().getPath() + "/" + TimeUtils.getTodayDateTime() + "sign.jpg";
                mLinePathView.save(path, true, 10);
                mI.success(path);
            } catch (IOException e) {
                MyLogger.i(e.getMessage());
                MyToast.show(e.getMessage());
            }
        } else {
            MyToast.show("您没有签名~");
        }

        dismiss();
    }

    public interface I {
        void success(String path);
    }

    public void setI(I i) {
        mI = i;
    }
}
